<?php

namespace Model;

use Think\Model;

class AuthModel extends Model {
	/**
	 * 处理权限表单信息
	 * @access public
	 * @param array $post
	 */
	function saveauth($post) {
		$newid = $this->add($post);
		if ($post['auth_pid'] == 0) {
			$auth_path = $newid;
		} else {
			$info = $this->find($post['auth_pid']);
			$auth_path = $info['auth_path'] . "-" .$newid;
		}
		$auth_level = substr_count($auth_path, '-');
		$sql = "update ts_auth set auth_path='$auth_path',auth_level='$auth_level' where auth_id='$newid'";
		return $this->execute($sql);
	}
}